﻿using SketchUpAPI.NET.Enums;
using SketchUpAPI.NET.SketchUp.Exception;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace SketchUpAPI.NET.Objects
{
    public class Layer : Entity
    {
        #region API 函数
        /// <summary>
        /// 创建一个图层
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        [DllImport(LIB)]
        static extern SUResult SULayerCreate(out IntPtr layer);

        /// <summary>
        /// 获取图层名称
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        [DllImport(LIB)]
        static extern SUResult SULayerGetName(IntPtr layer, ref IntPtr name);
        #endregion

        /// <summary>
        /// 图层名称
        /// </summary>
        public string Name
        {
            get
            {
                StringRef name = StringRef.Empty;
                SketchUpExceptionHelper.ThrowSUResult(SULayerGetName(Id, ref name.Id));
                return name.Dispose();
            }
        }

        internal Layer(IntPtr id)
        {
            Id = id;
        }
    }
}